home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / tsetguid.zip / TEA / SET / SAMPLE / GRIDLIST.JAV < prev    next >
Text File  |  1997-02-27  |  2KB  |  79 lines

  1. /*
  2.  * Copyright (c) 1996-1997, InetSoft Technology Corp, All Rights Reserved.
  3.  *
  4.  * The software and information contained herein are copyrighted and 
  5.  * proprietary to InetSoft Technology Corp. This software is furnished 
  6.  * pursuant to a written license agreement and may be used, copied, 
  7.  * transmitted, and stored only in accordance with the terms of such 
  8.  * license and with the inclusion of the above copyright notice. Please 
  9.  * refer to the file "COPYRIGHT" for further copyright and licensing 
  10.  * information. This software and information or any other copies 
  11.  * thereof may not be provided or otherwise made available to any 
  12.  * other person. 
  13.  */
  14. package tea.set.sample;
  15.  
  16. import java.applet.*;
  17. import java.awt.*;
  18. import java.io.*;
  19. import java.net.*;
  20. import tea.set.*;
  21.  
  22. /**
  23.  * This is a demo applet to show using tea.set.TextGrid to build a 
  24.  * multi column list with data imported from a delimited file.
  25.  *
  26.  * @see Grid
  27.  * @see TextGrid
  28.  * @version 1.3, 01/31/97
  29.  * @author InetSoft Technology Corp
  30.  */
  31. public class GridList extends Applet {
  32.    public void init() {
  33.       setLayout(new BorderLayout());
  34.       try {
  35.      URL url = new URL(getDocumentBase(), "GridList.txt");
  36.      InputStream input = url.openStream();
  37.      
  38.      // create a TextGrid by importing data from a delimited 
  39.      // text file
  40.      grid = new TextGrid(input, "|");
  41.      grid.setEditable(false);
  42.  
  43.      // set the column headers
  44.      grid.setColHeader(Tool.tokenize("Widget,Description,Category",","));
  45.      
  46.      // make the grid row and column selectable without 
  47.      // creating selectors (headers)
  48.      grid.setRowSelectable(true);
  49.      grid.setColSelectable(true);
  50.      
  51.      // add two pixel between rows
  52.      grid.setGap(Grid.ALL_CELL, Grid.ALL_CELL, new Insets(1, 0, 1, 0));
  53.      
  54.      // clear body ruling lines and set one ruling lines between
  55.      // header and body
  56.      grid.setRuling(Grid.NONE);
  57.      grid.setRuling(Grid.HEADER, Grid.ALL_CELL, Grid.HORIZONTAL);
  58.      
  59.      // set each alternate row to have different color
  60.      Color c = getBackground();
  61.      c = new Color(c.getRed()-25, c.getGreen()-25, c.getBlue()-25);
  62.      
  63.      for(int i = 1; i < grid.getRowCount(); i += 2) {
  64.         grid.setColor(i, Grid.ALL_CELL, c);
  65.      }
  66.      
  67.      // add a border using Effect3D and add scrolling support
  68.      // using Scroller
  69.      add("Center", 
  70.          new Effect3D(new Scroller(grid), Effect3D.RAISED_BORDER));
  71.       }
  72.       catch(Exception e) {
  73.      e.printStackTrace();
  74.       }
  75.    }
  76.  
  77.    private TextGrid grid;
  78. }
  79.